﻿// Write a program that creates an array containing all letters from the alphabet (A-Z). 
// Read a word from the console and print the index of each of its letters in the array.

using System;

class PrintEachLetterIndex
{
    static void Main()
    {
        // read word from the console
        Console.Write("Enter a word: ");
        string word = Console.ReadLine();

        // generate char array with alphabet
        char[] alphabet = new char[26];
        for (int i = 0; i < 26; i++)
        {
            alphabet[i] = (char)(i + (int)('a'));
        }

        // find alpha index
        for (int i = 0; i < word.Length; i++)
        {
            char alpha = word[i];
            int indexAlpha = Array.BinarySearch(alphabet, Char.ToLower(alpha));
            if (indexAlpha >= 0)
            {
                Console.WriteLine("{0} -> {1}", alpha, indexAlpha);
            }
            else
            {
                Console.WriteLine("{0} -> not an alpha", alpha);
            }
        }
    }
}